package org.sunrise.game.common.network.server;

import io.netty.channel.Channel;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class ConnectionManger {
    private static final ConcurrentHashMap<String, Connection> connections = new ConcurrentHashMap<>();
    public static void createConnect(String connectId, Channel channel) {
        connections.put(connectId, new Connection(connectId, channel));
    }
    public static void removeConnect(String connectId) {
        var Connection = connections.remove(connectId);
        Connection.getChannel().close();
    }
    public static Connection getConnect(String connectId) {
        return connections.get(connectId);
    }
    public static boolean isConnectExist(String connectId) {
        return connections.containsKey(connectId);
    }
    public static List<String> getConnects() {
        return new ArrayList<>(connections.keySet());
    }
}
